(0) Obligation:

The Runtime Complexity (innermost) of the given CpxTRS could be proven to be BOUNDS(1, 1).


The TRS R consists of the following rules:

fst(0, Z) → nil
fst(s, cons(Y)) → cons(Y)
from(X) → cons(X)
add(0, X) → X
add(s, Y) → s
len(nil) → 0
len(cons(X)) → s

Rewrite Strategy: INNERMOST

(1) TrsToWeightedTrsProof (BOTH BOUNDS(ID, ID) transformation)

Transformed TRS to weighted TRS

(2) Obligation:

The Runtime Complexity (innermost) of the given CpxWeightedTrs could be proven to be BOUNDS(1, 1).


The TRS R consists of the following rules:

fst(0, Z) → nil [1]
fst(s, cons(Y)) → cons(Y) [1]
from(X) → cons(X) [1]
add(0, X) → X [1]
add(s, Y) → s [1]
len(nil) → 0 [1]
len(cons(X)) → s [1]

Rewrite Strategy: INNERMOST

(3) TypeInferenceProof (BOTH BOUNDS(ID, ID) transformation)

Infered types.

(4) Obligation:

Runtime Complexity Weighted TRS with Types.
The TRS R consists of the following rules:

fst(0, Z) → nil [1]
fst(s, cons(Y)) → cons(Y) [1]
from(X) → cons(X) [1]
add(0, X) → X [1]
add(s, Y) → s [1]
len(nil) → 0 [1]
len(cons(X)) → s [1]

The TRS has the following type information:
fst :: 0:s → nil:cons → nil:cons
0 :: 0:s
nil :: nil:cons
s :: 0:s
cons :: a → nil:cons
from :: a → nil:cons
add :: 0:s → 0:s → 0:s
len :: nil:cons → 0:s

Rewrite Strategy: INNERMOST

(5) CompletionProof (UPPER BOUND(ID) transformation)

The TRS is a completely defined constructor system, as every type has a constant constructor and the following rules were added:

fst(v0, v1) → null_fst [0]
len(v0) → null_len [0]
add(v0, v1) → null_add [0]

And the following fresh constants:

null_fst, null_len, null_add, const

(6) Obligation:

Runtime Complexity Weighted TRS where all functions are completely defined. The underlying TRS is:

Runtime Complexity Weighted TRS with Types.
The TRS R consists of the following rules:

fst(0, Z) → nil [1]
fst(s, cons(Y)) → cons(Y) [1]
from(X) → cons(X) [1]
add(0, X) → X [1]
add(s, Y) → s [1]
len(nil) → 0 [1]
len(cons(X)) → s [1]
fst(v0, v1) → null_fst [0]
len(v0) → null_len [0]
add(v0, v1) → null_add [0]

The TRS has the following type information:
fst :: 0:s:null_len:null_add → nil:cons:null_fst → nil:cons:null_fst
0 :: 0:s:null_len:null_add
nil :: nil:cons:null_fst
s :: 0:s:null_len:null_add
cons :: a → nil:cons:null_fst
from :: a → nil:cons:null_fst
add :: 0:s:null_len:null_add → 0:s:null_len:null_add → 0:s:null_len:null_add
len :: nil:cons:null_fst → 0:s:null_len:null_add
null_fst :: nil:cons:null_fst
null_len :: 0:s:null_len:null_add
null_add :: 0:s:null_len:null_add
const :: a

Rewrite Strategy: INNERMOST

(7) CpxTypedWeightedTrsToRntsProof (UPPER BOUND(ID) transformation)

Transformed the TRS into an over-approximating RNTS by (improved) Size Abstraction.
The constant constructors are abstracted as follows:

0 => 1
nil => 0
s => 2
null_fst => 0
null_len => 0
null_add => 0
const => 0

(8) Obligation:

Complexity RNTS consisting of the following rules:

add(z, z') -{ 1 }→ X :|: z' = X, z = 1, X >= 0
add(z, z') -{ 1 }→ 2 :|: z = 2, z' = Y, Y >= 0
add(z, z') -{ 0 }→ 0 :|: v0 >= 0, v1 >= 0, z = v0, z' = v1
from(z) -{ 1 }→ 1 + X :|: X >= 0, z = X
fst(z, z') -{ 1 }→ 0 :|: Z >= 0, z = 1, z' = Z
fst(z, z') -{ 0 }→ 0 :|: v0 >= 0, v1 >= 0, z = v0, z' = v1
fst(z, z') -{ 1 }→ 1 + Y :|: z = 2, Y >= 0, z' = 1 + Y
len(z) -{ 1 }→ 2 :|: z = 1 + X, X >= 0
len(z) -{ 1 }→ 1 :|: z = 0
len(z) -{ 0 }→ 0 :|: v0 >= 0, z = v0

Only complete derivations are relevant for the runtime complexity.

(9) CompleteCoflocoProof (EQUIVALENT transformation)

Transformed the RNTS (where only complete derivations are relevant) into cost relations for CoFloCo:

eq(start(V, V1),0,[fst(V, V1, Out)],[V >= 0,V1 >= 0]).
eq(start(V, V1),0,[from(V, Out)],[V >= 0]).
eq(start(V, V1),0,[add(V, V1, Out)],[V >= 0,V1 >= 0]).
eq(start(V, V1),0,[len(V, Out)],[V >= 0]).
eq(fst(V, V1, Out),1,[],[Out = 0,Z1 >= 0,V = 1,V1 = Z1]).
eq(fst(V, V1, Out),1,[],[Out = 1 + Y1,V = 2,Y1 >= 0,V1 = 1 + Y1]).
eq(from(V, Out),1,[],[Out = 1 + X1,X1 >= 0,V = X1]).
eq(add(V, V1, Out),1,[],[Out = X2,V1 = X2,V = 1,X2 >= 0]).
eq(add(V, V1, Out),1,[],[Out = 2,V = 2,V1 = Y2,Y2 >= 0]).
eq(len(V, Out),1,[],[Out = 1,V = 0]).
eq(len(V, Out),1,[],[Out = 2,V = 1 + X3,X3 >= 0]).
eq(fst(V, V1, Out),0,[],[Out = 0,V2 >= 0,V3 >= 0,V = V2,V1 = V3]).
eq(len(V, Out),0,[],[Out = 0,V4 >= 0,V = V4]).
eq(add(V, V1, Out),0,[],[Out = 0,V5 >= 0,V6 >= 0,V = V5,V1 = V6]).
input_output_vars(fst(V,V1,Out),[V,V1],[Out]).
input_output_vars(from(V,Out),[V],[Out]).
input_output_vars(add(V,V1,Out),[V,V1],[Out]).
input_output_vars(len(V,Out),[V],[Out]).

CoFloCo proof output:
Preprocessing Cost Relations
=====================================

#### Computed strongly connected components
0. non_recursive : [add/3]
1. non_recursive : [from/2]
2. non_recursive : [fst/3]
3. non_recursive : [len/2]
4. non_recursive : [start/2]

#### Obtained direct recursion through partial evaluation
0. SCC is partially evaluated into add/3
1. SCC is completely evaluated into other SCCs
2. SCC is partially evaluated into fst/3
3. SCC is partially evaluated into len/2
4. SCC is partially evaluated into start/2

Control-Flow Refinement of Cost Relations
=====================================

### Specialization of cost equations add/3
* CE 11 is refined into CE [15]
* CE 10 is refined into CE [16]
* CE 9 is refined into CE [17]


### Cost equations --> "Loop" of add/3
* CEs [15] --> Loop 10
* CEs [16] --> Loop 11
* CEs [17] --> Loop 12

### Ranking functions of CR add(V,V1,Out)

#### Partial ranking functions of CR add(V,V1,Out)


### Specialization of cost equations fst/3
* CE 7 is refined into CE [18]
* CE 6 is refined into CE [19]
* CE 8 is refined into CE [20]


### Cost equations --> "Loop" of fst/3
* CEs [18] --> Loop 13
* CEs [19,20] --> Loop 14

### Ranking functions of CR fst(V,V1,Out)

#### Partial ranking functions of CR fst(V,V1,Out)


### Specialization of cost equations len/2
* CE 13 is refined into CE [21]
* CE 14 is refined into CE [22]
* CE 12 is refined into CE [23]


### Cost equations --> "Loop" of len/2
* CEs [21] --> Loop 15
* CEs [22] --> Loop 16
* CEs [23] --> Loop 17

### Ranking functions of CR len(V,Out)

#### Partial ranking functions of CR len(V,Out)


### Specialization of cost equations start/2
* CE 2 is refined into CE [24,25]
* CE 3 is refined into CE [26]
* CE 4 is refined into CE [27,28,29]
* CE 5 is refined into CE [30,31,32]


### Cost equations --> "Loop" of start/2
* CEs [24,28] --> Loop 18
* CEs [27] --> Loop 19
* CEs [25,26,29,30,31,32] --> Loop 20

### Ranking functions of CR start(V,V1)

#### Partial ranking functions of CR start(V,V1)


Computing Bounds
=====================================

#### Cost of chains of add(V,V1,Out):
* Chain [12]: 1
with precondition: [V=1,V1=Out,V1>=0]

* Chain [11]: 1
with precondition: [V=2,Out=2,V1>=0]

* Chain [10]: 0
with precondition: [Out=0,V>=0,V1>=0]


#### Cost of chains of fst(V,V1,Out):
* Chain [14]: 1
with precondition: [Out=0,V>=0,V1>=0]

* Chain [13]: 1
with precondition: [V=2,V1=Out,V1>=1]


#### Cost of chains of len(V,Out):
* Chain [17]: 1
with precondition: [V=0,Out=1]

* Chain [16]: 0
with precondition: [Out=0,V>=0]

* Chain [15]: 1
with precondition: [Out=2,V>=1]


#### Cost of chains of start(V,V1):
* Chain [20]: 1
with precondition: [V>=0]

* Chain [19]: 1
with precondition: [V=1,V1>=0]

* Chain [18]: 1
with precondition: [V=2,V1>=0]


Closed-form bounds of start(V,V1):
-------------------------------------
* Chain [20] with precondition: [V>=0]
- Upper bound: 1
- Complexity: constant
* Chain [19] with precondition: [V=1,V1>=0]
- Upper bound: 1
- Complexity: constant
* Chain [18] with precondition: [V=2,V1>=0]
- Upper bound: 1
- Complexity: constant

### Maximum cost of start(V,V1): 1
Asymptotic class: constant
* Total analysis performed in 67 ms.

(10) BOUNDS(1, 1)